var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var point3d = { x: 1, y: 2, z: 3 };
var Greeter1 = /** @class */ (function () {
    function Greeter1(message) {
        this.greeting = message;
    }
    Greeter1.prototype.greet = function () {
        return "Hello, " + this.greeting;
    };
    Greeter1.standarGreeting = 'Hello, there';
    return Greeter1;
}());
var greeter;
greeter = new Greeter1('word');
console.log(greeter.greet());
//重新创建一个
var greeterMaker = Greeter1;
greeterMaker.standarGreeting = 'Hey there';
var greeter2 = new greeterMaker();
console.log(greeter2.greet());
/* 抽象类 */
var Department = /** @class */ (function () {
    function Department(name) {
        this.name = name;
    }
    Department.prototype.printName = function () {
        console.log('Department name is ' + this.name);
    };
    return Department;
}());
var AccountingDepartment = /** @class */ (function (_super) {
    __extends(AccountingDepartment, _super);
    function AccountingDepartment() {
        return _super.call(this, 'Departmen Name Is ' + '研发部') || this;
    }
    AccountingDepartment.prototype.printMeeting = function () {
        console.log('继承了Department的派生类');
    };
    AccountingDepartment.prototype.generatorReport = function () {
        console.log('生成一个报告');
    };
    return AccountingDepartment;
}(Department));
var department;
// department = new Department();   //这是不行的
department = new AccountingDepartment();
department.printName();
department.printMeeting();
// 但是不能department.generatorReport();   因为department已经声明了Department类型
//派生类的基本长相
var AnimalabsTract = /** @class */ (function () {
    function AnimalabsTract() {
    }
    AnimalabsTract.prototype.move = function () {
        console.log('abstract');
    };
    return AnimalabsTract;
}());
/* 静态属性 */
var Grid = /** @class */ (function () {
    function Grid(scale) {
        this.scale = scale;
    }
    Grid.prototype.caculateDistanceFromOrigin = function (point) {
        var xDist = point.x - Grid.origin.x;
        var yDist = point.y - Grid.origin.y;
        return Math.sqrt(xDist * xDist + yDist * yDist) * this.scale;
    };
    Grid.origin = { x: 0, y: 0 };
    return Grid;
}());
var grid1 = new Grid(1.0);
var grid2 = new Grid(5.0);
console.log(grid1.caculateDistanceFromOrigin({ x: 3, y: 4 }));
console.log(grid2.caculateDistanceFromOrigin({ x: 3, y: 4 }));
/* 存取器 */
var passcode = 'hardy';
var Employee2 = /** @class */ (function () {
    function Employee2() {
    }
    Object.defineProperty(Employee2.prototype, "fullName", {
        get: function () {
            return this._fullName;
        },
        set: function (fullname) {
            if (fullname && fullname === 'hardy') {
                this._fullName = 'hardy 正确';
            }
            else {
                console.log('printf:' + fullname);
            }
        },
        enumerable: true,
        configurable: true
    });
    return Employee2;
}());
var employee2 = new Employee2();
employee2.fullName = '小方块';
if (employee2.fullName && employee2.fullName === 'hardy') {
    console.log(employee2.fullName, ':+++');
}
/**
 * 类 + 公共/私有 + 受保护符
 *
 public: Java语言中访问限制最宽的修饰符，一般称之为“公共的”。被其修饰的类、属性以及方法不
                      仅可以跨类访问，而且允许跨包（package）访问。
 private: Java语言中对访问权限限制的最窄的修饰符，一般称之为“私有的”。被其修饰的类、属性以
                     及方法只能被该类的对象访问，其子类不能访问，更不能允许跨包访问。
 protect: 介于public 和 private 之间的一种访问修饰符，一般称之为“保护形”。被其修饰的类、
      属性以及方法只能被类本身的方法及子类访问，即使子类在不同的包中也可以访问。
 * 成员默认为public
 * */
var Person2 = /** @class */ (function () {
    function Person2(name) {
        this.name = name;
    } //不建议这么写
    return Person2;
}());
var person1 = new Person2('小方块');
console.log(person1.name);
/*readyonly*/
var Person1 = /** @class */ (function () {
    function Person1(name) {
        this.name = name;
    }
    return Person1;
}());
var person = new Person1('Hardy');
person.name = '小方块';
console.log(person.name);
/*protected*/
var Person = /** @class */ (function () {
    function Person(name) {
        this.name = name;
    }
    return Person;
}());
var Employee1 = /** @class */ (function (_super) {
    __extends(Employee1, _super);
    function Employee1(name, department) {
        var _this = _super.call(this, name) || this;
        _this.department = department;
        return _this;
    }
    Employee1.prototype.getElevatorPitch = function () {
        return "hello my name is " + this.name + " and i work in " + this.department;
    };
    return Employee1;
}(Person));
var howard = new Employee1('Hardy', 'Development');
console.log(howard.getElevatorPitch());
// console.log(howard.name);  //但是外部访问不到里头的name
// let person = new Person('Hardy');  //报错，因为person的constructor是protected
/*private*/
var Animal1 = /** @class */ (function () {
    function Animal1(name) {
        this.name = name;
    }
    Animal1.prototype.move = function (distance) {
        if (distance === void 0) { distance = 5; }
        console.log(this.name + " is moved to " + distance);
    };
    return Animal1;
}());
var Rhino = /** @class */ (function (_super) {
    __extends(Rhino, _super);
    function Rhino(name) {
        return _super.call(this, name) || this;
    }
    return Rhino;
}(Animal1));
var Employee = /** @class */ (function () {
    function Employee(name) {
        this.name = name;
    }
    return Employee;
}());
var animal = new Animal1('HardyAnimal');
var rhino = new Rhino('HardyRhino');
var employee = new Employee('HardyEmployee');
// animal = rhino;       //可以
// animal = employee;    //报错
/**
 * 类 + 基本示例 + 继承
 * */
var Animal = /** @class */ (function () {
    function Animal(name) {
        this.name = name;
    }
    Animal.prototype.move = function (distance) {
        if (distance === void 0) { distance = 0; }
        console.log(this.name + " moved to " + distance);
    };
    return Animal;
}());
var Dog = /** @class */ (function (_super) {
    __extends(Dog, _super);
    function Dog() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    Dog.prototype.tick = function () {
        console.log('woof woof!!');
    };
    return Dog;
}(Animal));
var Horse = /** @class */ (function (_super) {
    __extends(Horse, _super);
    function Horse(name) {
        return _super.call(this, name) || this;
    }
    Horse.prototype.move = function (distance) {
        if (distance === void 0) { distance = 100; }
        _super.prototype.move.call(this, distance);
    };
    return Horse;
}(Animal));
var horse = new Horse('Hardy');
horse.move(1000);
var dog = new Dog('小白');
dog.tick();
dog.move(20);
var Greeter = /** @class */ (function () {
    function Greeter(message) {
        this.greeting = message;
    }
    Greeter.prototype.greet = function () {
        return "hello " + this.greeting;
    };
    return Greeter;
}());
var greet = new Greeter('hardy');
console.log(greet.greet());
